import java.util.Arrays;
import java.util.Comparator;

public class LargestNumber {

    public String largestNumber(int[] nums) {
        Integer newNums[] = Arrays.stream(nums).boxed().toArray(Integer[]::new);
        Arrays.sort(newNums, new pare());
        StringBuilder stringBuilder = new StringBuilder();
        for (int i = 0; i < newNums.length; i++) {
            if (stringBuilder.length() == 0 && newNums[i] == 0) continue;
            stringBuilder.append(newNums[i]);
        }
        if (stringBuilder.length() == 0) return "0";
        return stringBuilder.toString();
    }

}

class pare implements Comparator<Integer> {

    @Override
    public int compare(Integer o1, Integer o2) {
        String s1 = o1 + "";
        String s2 = o2 + "";
        String ans1 = s1 + s2;
        String ans2 = s2 + s1;
        if (Long.parseLong(ans2) - Long.parseLong(ans1) >= 0) {
            return 1;
        } else return -1;
    }
}
